import React from "react";
import {
    useRoutes
} from "react-router-dom";
import CircularProgress from '@mui/material/CircularProgress';
import ChatPageWrapper from "../view/pages/chat/ChatPage.jsx";



const HomePage = React.lazy(() => import('../view/pages/home/Dashboard.jsx'))

const Login = React.lazy(() => import('../view/Login.jsx'))
const NotFound = React.lazy(() => import('../view/NotFound.jsx'))
// const SignInPage = React.lazy(() => import('./pages/Auth/SignIn'))



const Loading = () => {
    return (
        <CircularProgress />
    )
}


const EchoUseRoutes = () => {
   const routes =  useRoutes([
        {
            children: [
                {
                    path: "/dashboard/*",
                    element:
                        <React.Suspense fallback={<Loading />}>
                            <HomePage />
                        </React.Suspense>
                    ,
                    meta: {
                        title: "dashboard页",
                        key: "dashboard",

                        // superAdmin: true,
                        roles: ['superAdmin', 'admin'],
                    }
                }
                , {
                    path: "/chatlocal",
                    element: <React.Suspense fallback={<Loading />}>
                        <ChatPageWrapper />
                    </React.Suspense>,
                    meta: {
                        title: "聊天页",
                        key: "chatlocal"
                    }
                },
                , {
                    path: "/login",
                    element: <React.Suspense fallback={<Loading />}>
                        <Login />
                    </React.Suspense>,
                    meta: {
                        title: "登录页",
                        key: "login"
                    }
                },
                , {
                    path: "*",
                    element: <NotFound />,
                    meta: {
                        title: "404",
                        key: "404"
                    }
                },
            ]
        }
    ])

    return routes
}



export default EchoUseRoutes
